<?php

namespace App\Http\Controllers\Auth;

use App\Facades\Tx;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use App\User;
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;

class RegisterController extends Controller
{


    public function register(Request $request)
    {
        $this->validate($request,
            [
                'username' => ['required', 'string', 'max:255'],
                'phone' => ['required', 'string', 'unique:users'],
                'password' => ['required', 'string', 'min:8'],
            ]);

        return Tx::success(
            User::create([
            'username' => $request->get('username'),
            'phone' => $request->get('phone'),
            'password' => md5(trim($request->get('password'))),
            ])
        );
    }
}
